package com.example.myengine.engine;

import com.example.myengine.request.RuleExecuteReq;
import com.example.myengine.vo.TreeNodeLineVO;

import java.util.List;


/**
 * @author ycd0075
 * @date 2024-02-02 17:07
 */
public abstract class BaseLogicFilter implements LogicFilter {



    @Override
    public Long filter(String matterValue, List<TreeNodeLineVO> treeNodeLineInfoList) {
        for (TreeNodeLineVO nodeLine : treeNodeLineInfoList) {
            if (decisionLogic(matterValue, nodeLine)) {
                return nodeLine.getNodeIdTo();
            }
        }
        return 0L;
    }

    /**
     * 获取规则比对值
     *
     * @param decisionMatter 决策物料
     * @return 比对值
     */
    @Override
    public abstract String matterValue(RuleExecuteReq decisionMatter);

    /**
     * 匹配规则是否成功
     *
     * @param matterValue 决策物料
     * @param nodeLine    节点线
     * @return 是否通过
     */

    public abstract boolean decisionLogic(String matterValue, TreeNodeLineVO nodeLine);

}
